-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add experimental AwsTerraformAdapter
to support interoperability with AWS CDK constructs
#1123
Conversation
… level for `nested_type`s
… level for `nested_type`s
…c lambda defaults
re-uses the existing interface of a post processor to be able to apply changes to a lazy value after it resolved lazily. This functionality is then used for marking and TFExpression as an inner one to be able to reference attributes of mapped resources correctly in the resulting Terraform config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to mostly just be work that's also in other PRs. How much of what is here is actually unique / used anymore?
@@ -84,6 +84,7 @@ | |||
"@typescript-eslint/eslint-plugin": "^4.28.1", | |||
"@typescript-eslint/parser": "^4.28.1", | |||
"constructs": "^10.0.0", | |||
"aws-cdk-lib": "2.0.0-rc.23", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there anyway to not take a hard dependency here?
@@ -22,7 +22,7 @@ export class TerraformDataSource | |||
// TerraformMetaArguments | |||
|
|||
public dependsOn?: string[]; | |||
public count?: number; | |||
public count?: number | IResolvable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was already merged in a different PR, but ultimately keeping as a number would be ideal.
description?: string; | ||
required?: boolean; | ||
optional?: boolean; | ||
computed?: boolean; | ||
sensitive?: boolean; | ||
} | ||
|
||
interface NestedTypeAttribute extends BaseAttribute { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the plan to merge the other PR, or just include in this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turned out that the other PR was not needed for this to work as we now use the aws_cloudcontrolapi_resource
instead of the awscc provider. Also: the adapter code moved to https://github.com/hashicorp/cdktf-aws-cdk
So this PR only serves as a checklist and will be closed soon.
} | ||
|
||
private emitToTerraformFuction(struct: Struct) { | ||
this.code.line(); | ||
this.code.openBlock( | ||
`function ${downcaseFirst(struct.name)}ToTerraform(struct?: ${ | ||
`export function ${downcaseFirst(struct.name)}ToTerraform(struct?: ${ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this add a bunch of jsii warning?
// are exported for now. We might want to improve the control flow | ||
// here in way to determine which structs need really this function | ||
// and which don't. | ||
// TODO: only do this if the parent of this struct needs it to be exported because any parent might expose it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it just structs belonging to nested types that need this?
As described in the PR description: The adapter moved to a separate repo and hence this PR will never be merged, as the code lives here now: hashicorp/cdktf-aws-cdk. I created follow-up issues for all remaining tasks that did not make it into the initial increment. Closing this 👋 |
I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This PR adds an experimental adapter which can be used to deploy AWS CDK (v2) constructs using CDK for Terraform.
It uses the new Cloud Control API (specifically the
awscc
Terraform provider) to provision resources using Terraform.The branch is based on the
support-nested-type
branch (PR) as theawscc
provider makes use of those new types.For resources that are not yet available in the Cloud Control API (e.g. IAM resources) a custom mapping can be supplied instead. We plan to include some of these mappings already but cannot guarantee completeness.
Resolves #244, Relates to #474
local development instructions
The `aws-adapter` package currently depends on `@cdktf/provider-aws` which in turn depends on `cdktf=^0.6` which blocks us from testing local changes to the `cdktf` package (because JSII is very strict about versions and the work in progress version is of the `cdktf` is `0.0.0`. Hence some extensive linking is required:Open tasks
@cdktf/aws-adapter
packageawscc
provider resourcesFn::Sub
)propertyAccess / markAsInner
forRef
s (see test case forFn::FindInMap
)@cdktf/aws-adapter
with[email protected]
without JSII failingcdktf-aws-cdk
) and rename package to@cdktf/aws-cdk
aws_cloudcontrolapi_resource
instead of individual resources (we don't have to convert the attribute names this way)Outputs
property of Cfn templatetfExpression.ts
AwsTerraformAdapter
Follow-up tasks
(to be tracked as separate issues)
Fn::Cidr
andFn::Sub
) E2E test intrinsic CloudFormation functions cdktf-aws-cdk#144AWS::NoValue
for Conditions (removes an attribute from the config/props – maybe we can just useundefined
) (example) SupportAWS::NoValue
for Conditions cdktf-aws-cdk#145registerMapping
for other languages via JSII (probably designed as a builder pattern) Expose interface forregisterMapping
for other languages via JSII cdktf-aws-cdk#150@cdktf/aws-adapter
package (for Python, C#, Java, JS & Go) Set-up publishing of@cdktf/aws-adapter
package for Python, C#, Java & Go cdktf-aws-cdk#151Deferred to later iterations